/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package VOs;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Julian
 */
@Entity
@Table(name = "PLAN")
@NamedQueries({
    @NamedQuery(name = "Plan.findAll", query = "SELECT p FROM Plan p"),
    @NamedQuery(name = "Plan.findByIdPlan", query = "SELECT p FROM Plan p WHERE p.idPlan = :idPlan")})
public class Plan implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_PLAN")
    private BigDecimal idPlan;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkPlan")
    private Collection<Reserve> reserveCollection;
    @JoinColumn(name = "FK_USERNAME", referencedColumnName = "USERNAME")
    @ManyToOne(optional = false)
    private Users fkUsername;

    public Plan() {
    }

    public Plan(BigDecimal idPlan) {
        this.idPlan = idPlan;
    }

    public BigDecimal getIdPlan() {
        return idPlan;
    }

    public void setIdPlan(BigDecimal idPlan) {
        this.idPlan = idPlan;
    }

    public Collection<Reserve> getReserveCollection() {
        return reserveCollection;
    }

    public void setReserveCollection(Collection<Reserve> reserveCollection) {
        this.reserveCollection = reserveCollection;
    }

    public Users getFkUsername() {
        return fkUsername;
    }

    public void setFkUsername(Users fkUsername) {
        this.fkUsername = fkUsername;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPlan != null ? idPlan.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Plan)) {
            return false;
        }
        Plan other = (Plan) object;
        if ((this.idPlan == null && other.idPlan != null) || (this.idPlan != null && !this.idPlan.equals(other.idPlan))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "VOs.Plan[idPlan=" + idPlan + "]";
    }

}
